<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    	<%
		if(session.getAttribute("isAdminLogined")==null){
			return;
		}else{
			String isAddminLogined = session.getAttribute("isAdminLogined").toString();
			if(!("true".equals(isAddminLogined))){
				response.sendRedirect("login.jsp");
				return;
			}
		}
		
	%>
    <%@page import="com.doone.telmarket.domain.ServicePage"%>
<%
	ServicePage servicePage = null;
	System.out.println("serviceTemplet.jsp servicePage:"+session.getAttribute("servicePage")+":jsessionid="+session.getId());
	if(session.getAttribute("servicePage")!=null){
		servicePage = (ServicePage)session.getAttribute("servicePage");
	}else{
		return;
	}
	
	String acceptState = "";

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<%@page import="java.math.BigDecimal"%>
<%@page import="java.util.List"%>
<%@page import="com.doone.telmarket.domain.ServicePageContent"%>
<%@page import="com.doone.telmarket.domain.ServiceProduct"%><html>
<head>
<META   HTTP-EQUIV="Pragma"   CONTENT="no-cache">    
<META   HTTP-EQUIV="Cache-Control"   CONTENT="no-cache">    
<META   HTTP-EQUIV="Expires"   CONTENT="0">   
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>增值业务门户</title>
    <link href="${pageContext.request.contextPath}/css/style.css" rel="stylesheet" type="text/css" />
    <link href="${pageContext.request.contextPath}/css/style_link.css" rel="stylesheet" type="text/css" />
    <link href="${pageContext.request.contextPath}/css/tab.css" rel="stylesheet" type="text/css" />
    <SCRIPT src="${pageContext.request.contextPath}/js/tab.js" type=text/javascript></SCRIPT>
    <script src="${pageContext.request.contextPath}/js/jquery.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath}/js/jquery.ui.draggable.js"
	type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.alerts.js"
	type="text/javascript"></script>
<link href="${pageContext.request.contextPath}/css/jquery.alerts.css"
	rel="stylesheet" type="text/css" media="screen" />
	<script type="text/javascript">


	function submitForm(mode){
		document.getElementById("actionUrl").value = mode;
		document.getElementById("productForm").submit();
		
		
	}
	function changeProductId(){
		var proid = document.getElementById("productIdSelect");
		var arry = proid.options[proid.options.selectedIndex].value.split("~");
		document.getElementById("businame").value = proid.options[proid.options.selectedIndex].text;
		document.getElementById("productId").value = arry[0];
		document.getElementById("fee").value = arry[1]+"元";
		document.getElementById("productDesc").innerHTML = "";
		document.getElementById("productDesc").innerHTML = arry[2];
		if(arry[3]=="D"){
			document.getElementById("wydg").style.display="none";
			document.getElementById("wytd").style.display="none";
			document.getElementById("wydg2").style.display="";
			document.getElementById("wytd2").style.display="";
		}else{
			document.getElementById("wydg").style.display="";
			document.getElementById("wytd").style.display="";
			document.getElementById("wydg2").style.display="none";
			document.getElementById("wytd2").style.display="none";
		}
	}

	function keep(url,serviceCode,servicePage,serviceName){
		$.ajax  
	    (   
	        {   
	            url:url,    
	            type: 'POST',
	            data: "serviceCode="+serviceCode+"&pageUrl="+servicePage+"&serviceName="+serviceName,
	            timeout:10000,
	            success: function(msg)   
	            {
	        	jAlert(msg,'消息');
	            },   
	            error: function (msg)   
	            {   
	            	jAlert('很抱歉,收藏增值业务失败','消息');
	            }   
	        }   
	    ); 
	}

	window.onload = function(){
		//var proid = document.getElementById("productIdSelect");
		//var arry = proid.options[proid.options.selectedIndex].value.split("~");


		
		
		if(document.getElementById("acceptState").value!="D"){

			
			document.getElementById("wydg").style.display="";
			document.getElementById("wytd").style.display="";
		}
		
		var productid = $("#productId").val();
		var serviceCode = $("#serviceCode").val();
		getBuyCountByProduct(productid,serviceCode);
	}

	function getBuyCountByProduct(id,serviceCode){
		var contex = $("#context").val();
		$.ajax  
	    (   
	        {   
	            url:contex+'/web/getBuyCountAndScCount',    
	            type: 'POST',
	            data: "serviceCode="+serviceCode+"&productid="+id,
	            timeout:15000,
	            success: function(msg)   
	            {
	        	if(msg!="F"){
					var arr = msg.split("~");
					document.getElementById("buyCount").innerHTML = "";
					document.getElementById("shoucang").innerHTML = "";
					document.getElementById("buyCount").innerHTML = arr[0];
					document.getElementById("shoucang").innerHTML = arr[1];
			     }else{
				    }
	            },   
	            error: function (msg)   
	            {   
	            	jAlert('很抱歉,收藏增值业务失败','消息');
	            }   
	        }   
	    ); 
	}
	</script>
</head><center>
<body>
<%
	 List<ServiceProduct> proLi = servicePage.getService().getProducts();
	 
	 %>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><input type="hidden" id="context" value="${pageContext.request.contextPath}"><iframe src="${pageContext.request.contextPath}/web/common/head.jsp" width="100%" height="267" frameborder="0"  marginwidth="0" marginheight="0"  scrolling="no"></iframe></td>
  </tr>
</table>
<table width="987" border="0" cellpadding="0" cellspacing="0" style="margin-bottom:8px;">
  <tr>
    <td height="16" align="left" valign="middle" class="huise_12">&nbsp;<a href="${pageContext.request.contextPath}/web/index.htm">超市首页 </a>&gt; <%=servicePage.getService().getServiceType().getServiceTypeName() %> &gt; <%=servicePage.getService().getServiceClassify().getServiceClassifyName() %></td>
  </tr>
</table>
<iframe src="${pageContext.request.contextPath}/admin/templete/classification.jsp" width="100%" height="50px" frameborder="0"  marginwidth="0" marginheight="0"  scrolling="no"></iframe>
<table width="987" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="214" height="500" align="left" valign="top">
    <iframe src="${pageContext.request.contextPath}/web/common/m_left.jsp" width="100%" height="308px" frameborder="0"  marginwidth="0" marginheight="0"  scrolling="no"></iframe>
    <iframe src="${pageContext.request.contextPath}/web/common/imusicSort.html" width="100%" height="322px" frameborder="0"  marginwidth="0" marginheight="0"  scrolling="no"></iframe>
    </td>
    <td width="773" align="right" valign="top">
     
       
    
    <table width="769" height="222" border="0" cellpadding="0" cellspacing="0" style="margin-bottom:8px;">
      <tr>
        <td width="271" height="222" align="left" valign="top"><table width="266" height="152" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td height="220" align="left" valign="top"><table width="258" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="212" align="center" style="border:1px solid #dfe8ef;"><img src="${pageContext.request.contextPath}<%=servicePage.getPageLogoPath() %>" width="198" height="177" /></td>
                </tr>
              </table></td>
            </tr>
            
          </table>
            <table width="266" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="2"></td>
              </tr>
          </table></td>
        <td width="499" height="222" align="left" valign="middle"><table width="491" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="35" colspan="2" class="heise_B_14">业务名称：<%=servicePage.getService().getServiceName() %></td>
            <td height="35" class="heise_B_14"><span class="huise3_12">提供商：<%=servicePage.getService().getSpName() %></span>
             <input type="hidden" id="serviceCode" value="<%=servicePage.getService().getServiceCode() %>">
            <form action="${pageContext.request.contextPath}/web/verify.jsp" id="productForm" method="post">
                    <input type="hidden" id="businame" name="businame" value="<%=servicePage.getService().getProducts().get(0).getProductName() %>">
                     <input type="hidden" id="actionUrl" name="actionUrl">
                      <input type="hidden" id="orderMode" name="orderMode" value="<%=servicePage.getServiceOrder().getOrderMode() %>">
                     <input type="hidden" name="productId" id="productId" value="<%=servicePage.getService().getProducts().get(0).getProductId() %>">
              		<input type="hidden" id="fee" name="fee" value="<%=servicePage.getService().getProducts().get(0).getProductCost().getMoney().divide(new BigDecimal(100)) %>元" >
              	</form>
            </td>
            </tr>
          <tr>
            <td width="350" height="35" colspan="3" align="left" class="huise3_12"><span class="hongse_B_14">订购价格：
            
            <%
     				if(proLi.size()>1){
     					%>
     				   <select id="productIdSelect" onchange="changeProductId();" style="font: left">
     						<%
     						List<ServiceProduct> proList = proLi;
     							for(int i=0;i<proList.size();i++){
     								if(i==0){
     									acceptState = proList.get(i).getCanAccept();
     								}
     								%>
     		     					  <option value="<%=proList.get(i).getProductId() %>~<%=proList.get(i).getCost().divide(new BigDecimal(100)) %>~<%=proList.get(i).getProductSummary() %>~<%=proList.get(i).getCanAccept() %>"><%=servicePage.getService().getProducts().get(i).getProductName() %>(<%=servicePage.getService().getProducts().get(i).getProductCost().getMoney().divide(new BigDecimal(100)) %>元/月)</option>
     		     					<%
     							}
     						%>
     					</select>
     					 <%
     				}else{
     					acceptState = proLi.get(0).getCanAccept();
     					%> 
     					<%=servicePage.getService().getProducts().get(0).getProductName() %>(<%=proLi.get(0).getCost().divide(new BigDecimal(100)) %>元/月)
     					<%
     				}
     			%>   
            
            </span></td>
            <td width="94">&nbsp;<input type="hidden" id="acceptState" value="<%=acceptState %>" /></td>
            <td width="40">&nbsp;</td>
          </tr>
          <tr>
            <td height="35" class="huise3_12">分类：<%=servicePage.getService().getServiceClassify().getServiceClassifyName() %></td>
           
            
            <td height="35" class="huise3_12">推荐星级：    <%
              		for(int i=0;i<servicePage.getRecommandGrade();i++){
              			%><img src="${pageContext.request.contextPath}/images/list/rihgt_4.gif" width="13" height="12" /><%
              		}
              %></td>
            <td height="35" class="huise3_12">&nbsp;</td>
            <td height="35" class="huise3_12">&nbsp;</td>
          </tr>
          <tr>
            <td height="35" class="huise3_12">订购人气：<span id="buyCount">0</span>次</td>
            <td height="35" class="huise3_12">收藏人气：<span id="shoucang">0</span>次</td>
            <td height="35" class="huise3_12">&nbsp;</td>
            </tr>
          <tr>
            <td height="35" colspan="3" align="left"><span class="huise3_12">支持终端：</span><span class="huise3_12" id="productDesc">
                          	<%=proLi.get(0).getProductSummary() %>
                         </span></td>
            </tr>
          <tr align="left">
          <td colspan="3" align="center" ><table width="460" border="0" cellpadding="0" cellspacing="0">
              <tr>
          <%
          		if(!("//flash//emptyFlash.swf".equals(servicePage.getPageFlashPath()))){
          			%>	
          	
                <td><table width="80" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="80" align="center" style="cursor: hand" onclick="window.open('${pageContext.request.contextPath}/web/showFlash.jsp?flash=<%=servicePage.getPageFlashPath() %>')" background="${pageContext.request.contextPath}/images/bnt_dg.gif" >
                <img src="${pageContext.request.contextPath}/images/wyty.gif"  /></td>
              </tr>
            </table></td>
          			<%
          		}else{
          			%>
          	
          			<%
          		}
          %>
            
                <td align="left"><table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="80" align="center"  style="cursor: hand" onclick="keep('${pageContext.request.contextPath}/web/keepValueAdded',<%=servicePage.getServiceCode() %>,'<%=servicePage.getPageUrl() %>','<%=servicePage.getService().getServiceName() %>');" background="${pageContext.request.contextPath}/images/wysc.gif">
                <img src="${pageContext.request.contextPath}/images/wysc.gif" /></td>
              </tr>
            </table></td>
                <%
              	if("RDT".equals(servicePage.getServiceOrder().getOrderMode())){
              		%> 
              		<td id="wydg" style="display:none;"><table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="109" align="center"  style="cursor: hand"  onclick="window.open('<%=servicePage.getServiceOrder().getRedirectUrl() %>');" background="${pageContext.request.contextPath}/images/bnt_dg.gif">
                <img src="${pageContext.request.contextPath}/images/wydg.gif" /></td>
              </tr>
            </table></td>
                <td id="wytd" style="display:none;"><table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="109" align="center"  style="cursor: hand"  onclick="window.open('<%=servicePage.getServiceOrder().getRedirectUrl() %>');" background="${pageContext.request.contextPath}/images/bnt_dg.gif">
                <img src="${pageContext.request.contextPath}/images/wytd.gif" /></td>
              </tr>
            </table></td>
              		<%
              	}else if("SSO".equals(servicePage.getServiceOrder().getOrderMode())){
              		//单点登陆
              	}else{
              		%> 
              		<td id="wydg" style="display:none;"><table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="109" align="center"  style="cursor: hand"  onclick="submitForm('buyValueAdded')" background="${pageContext.request.contextPath}/images/bnt_dg.gif">
                <img src="${pageContext.request.contextPath}/images/wydg.gif" /></td>
              </tr>
            </table></td>
                <td id="wytd" style="display:none;"><table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="109" align="center"  style="cursor: hand"  onclick="submitForm('cancelValueAdded')" background="${pageContext.request.contextPath}/images/bnt_dg.gif">
                <img src="${pageContext.request.contextPath}/images/wytd.gif" /></td>
              </tr>
            </table></td>
           
              		<%
              	}
              %>
               
             
              </tr>
            </table></td>
            </tr>
        </table></td>
      </tr>
    </table>
    
    
    
    
    
      <table width="771" height="26" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="10"><img src="${pageContext.request.contextPath}/images/list/index_2.gif" width="10" height="30" /></td>
          <td width="751" background="${pageContext.request.contextPath}/images/list/index_3.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="647" height="30" align="left" valign="middle" class="baise_14"><table border="0" cellspacing="0" cellpadding="0"  id="secTable_st_d">
                <tr>
                  <%
                  			
                  		List<ServicePageContent> li = servicePage.getContents();
                		for(int i=0;i<li.size();i++){
                        	ServicePageContent s = li.get(i);
                        	if(i==0){
                        		%>
                        		<td height="28" align="center" class="sec_10" onclick="secBoard_st_d(<%=i %>)"><%=s.getTitle() %></td>
                        		<%
                        	}else{
                        		%>
                          		<td align="center" class="sec_9" onclick="secBoard_st_d(<%=i %>)"><%=s.getTitle() %></td>
                            	<%
                        	}
                        }
                  	%>
                </tr>
              </table>
              		
              </td>
              <td width="104" height="30" align="center" valign="bottom">&nbsp;</td>
            </tr>
          </table></td>
          <td width="10" align="right"><img src="${pageContext.request.contextPath}/images/list/index_4.gif" width="10" height="30" /></td>
        </tr>
      </table>
      <table width="771" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td height="350" align="center" valign="top" style="border-left:1px solid #c2282a; border-right:1px solid #c2282a;">
          
          <table width="724" border="0" align="center" cellpadding="0" height="300" cellspacing="0" id="mainTable_st_d" style="margin-top:20px; margin-bottom:20px;">
                <%
                		for(int i=0;i<li.size();i++){
                        	ServicePageContent s = li.get(i);
                        	if(i==0){
                        		%>
                        	<tbody style="display:block;">
             					 <tr>
                					<td height="131" align="left" valign="top"><%=s.getContent() %></td>
              					</tr>
            				</tbody>	
                        		<%
                        	}else{
                        		%>
                           <tbody style="display:none;">
             					 <tr>
                					<td height="131" align="left" valign="top"><%=s.getContent() %></td>
              					</tr>
            				</tbody>
                            	<%
                        	}
                        }
                  	%>
          </table></td>
        </tr>
      </table>
      <table width="771" border="0" cellspacing="0" cellpadding="0" style="margin-bottom:8px;">
        <tr>
          <td width="10"><img src="${pageContext.request.contextPath}/images/tab_foot_1.gif" width="10" height="6" /></td>
          <td width="751" background="${pageContext.request.contextPath}/images/tab_foot_2.gif"></td>
          <td width="10"><img src="${pageContext.request.contextPath}/images/tab_foot_3.gif" width="10" height="6" /></td>
        </tr>
      </table>
      
      
      
      </td>
  </tr>
</table>
     
<table width="986" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><iframe src="${pageContext.request.contextPath}/web/common/footer.html"  width="100%" height="167px" frameborder="0"  marginwidth="0" marginheight="0" scrolling="no"></iframe></td>
  </tr>
</table>
</body></center>
</html>